package com.ehi.queue.resource;

import com.ehi.common.jersey.status.ResponseBuilder;
import com.ehi.queue.repository.JmsProducer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

@Component
@Path("/")
public class JmsQueueResource {

    @Autowired
    private JmsProducer producer;

    @Path("producer")
    @Produces(MediaType.APPLICATION_JSON)
    @GET
    public Response sendMessage(@QueryParam("msg") String msg) {
        producer.send(msg);
        return ResponseBuilder.ok("OK");
    }

    @GET
    @Path("/echo")
    public String echo() {
        return "Hello Spring Boot2";
    }
}
